//
//  MyTakeOrderDetailInfoCell.m
//  ReceiptDelivery
//
//  Created by 吕晶 on 2021/1/27.
//  Copyright © 2021 吕晶. All rights reserved.
//

#import "MyTakeOrderDetailInfoCell.h"

@interface MyTakeOrderDetailInfoCell ()

@property (nonatomic, strong) UIView *bgView;
@property (nonatomic, strong) UILabel *fanWeiTitleLab;
@property (nonatomic, strong) UILabel *fanWeiLab;
@property (nonatomic, strong) UILabel *leiXingTitleLab;
@property (nonatomic, strong) UILabel *leiXingLab;
@property (nonatomic, strong) UILabel *companyTitleLab;
@property (nonatomic, strong) UILabel *companyLab;
@property (nonatomic, strong) UILabel *priceTitleLab;
@property (nonatomic, strong) UILabel *priceLab;

@property (nonatomic, strong) UILabel *timeTitleLab;
@property (nonatomic, strong) UILabel *beignTimeLab;
@property (nonatomic, strong) UILabel *endTimeLab;
@property (nonatomic, strong) UIView *beginDotView;
@property (nonatomic, strong) UIView *endDotView;
@property (nonatomic, strong) UILabel *timeLine;

@property (nonatomic, strong) UILabel *yaoQiuTitleLab;
@property (nonatomic, strong) UILabel *yaoQiuLab;
@property (nonatomic, strong) UILabel *jiaZhiTitleLab;
@property (nonatomic, strong) UILabel *jiaZhiLab;

@end

@implementation MyTakeOrderDetailInfoCell

+ (instancetype)MyTakeOrderDetailInfoCellWithTableView:(UITableView *)tableView {
    static NSString *cellID = @"MyTakeOrderDetailInfoCell";
    MyTakeOrderDetailInfoCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (cell == nil) {
        cell = [[MyTakeOrderDetailInfoCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
    }
    return cell;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.backgroundColor = Color_backgroundColor;
        
        self.bgView = [UIView new];
        self.bgView.backgroundColor = HexColor(0xffffff);
        self.bgView.layer.masksToBounds = YES;
        self.bgView.layer.cornerRadius = 6;
        [self.contentView addSubview:self.bgView];
        
        self.fanWeiTitleLab = [UILabel new];
        self.fanWeiTitleLab.textColor = HexColor(0x9C9DB3);
        self.fanWeiTitleLab.font = [UIFont systemFontOfSize:14];
        [self.bgView addSubview:self.fanWeiTitleLab];
        
        self.fanWeiLab = [UILabel new];
        self.fanWeiLab.textColor = HexColor(0x2B2C44);
        self.fanWeiLab.font = [UIFont systemFontOfSize:14];
        self.fanWeiLab.textAlignment = NSTextAlignmentRight;
        [self.bgView addSubview:self.fanWeiLab];
        
        self.leiXingTitleLab = [UILabel new];
        self.leiXingTitleLab.textColor = HexColor(0x9C9DB3);
        self.leiXingTitleLab.font = [UIFont systemFontOfSize:14];
        [self.bgView addSubview:self.leiXingTitleLab];
        
        self.leiXingLab = [UILabel new];
        self.leiXingLab.textColor = HexColor(0x2B2C44);
        self.leiXingLab.font = [UIFont systemFontOfSize:14];
        self.leiXingLab.textAlignment = NSTextAlignmentRight;
        [self.bgView addSubview:self.leiXingLab];
        
        self.companyTitleLab = [UILabel new];
        self.companyTitleLab.textColor = HexColor(0x9C9DB3);
        self.companyTitleLab.font = [UIFont systemFontOfSize:14];
        [self.bgView addSubview:self.companyTitleLab];
        
        self.companyLab = [UILabel new];
        self.companyLab.textColor = HexColor(0x2B2C44);
        self.companyLab.font = [UIFont systemFontOfSize:14];
        self.companyLab.textAlignment = NSTextAlignmentRight;
        [self.bgView addSubview:self.companyLab];
        
        self.priceTitleLab = [UILabel new];
        self.priceTitleLab.textColor = HexColor(0x9C9DB3);
        self.priceTitleLab.font = [UIFont systemFontOfSize:14];
        [self.bgView addSubview:self.priceTitleLab];
        
        self.priceLab = [UILabel new];
        self.priceLab.textColor = HexColor(0x2B2C44);
        self.priceLab.font = [UIFont systemFontOfSize:14];
        self.priceLab.textAlignment = NSTextAlignmentRight;
        [self.bgView addSubview:self.priceLab];
        
        self.timeTitleLab = [UILabel new];
        self.timeTitleLab.textColor = HexColor(0x9C9DB3);
        self.timeTitleLab.font = [UIFont systemFontOfSize:14];
        [self.bgView addSubview:self.timeTitleLab];
        
        self.beignTimeLab = [UILabel new];
        self.beignTimeLab.textColor = HexColor(0x2B2C44);
        self.beignTimeLab.font = [UIFont systemFontOfSize:14];
        [self.bgView addSubview:self.beignTimeLab];
        
        self.endTimeLab = [UILabel new];
        self.endTimeLab.textColor = HexColor(0x2B2C44);
        self.endTimeLab.font = [UIFont systemFontOfSize:14];
        [self.bgView addSubview:self.endTimeLab];
        
        self.beginDotView = [UIView new];
        self.beginDotView.backgroundColor = HexColor(0x2B2C44);
        [self.bgView addSubview:self.beginDotView];
        
        self.endDotView = [UIView new];
        self.endDotView.backgroundColor = HexColor(0x2B2C44);
        [self.bgView addSubview:self.endDotView];
        
        self.timeLine = [UILabel new];
        self.timeLine.backgroundColor = HexColor(0xBDBED9);
        [self.bgView addSubview:self.timeLine];
        
        self.yaoQiuTitleLab = [UILabel new];
        self.yaoQiuTitleLab.textColor = HexColor(0x9C9DB3);
        self.yaoQiuTitleLab.font = [UIFont systemFontOfSize:14];
        [self.bgView addSubview:self.yaoQiuTitleLab];
        
        self.yaoQiuLab = [UILabel new];
        self.yaoQiuLab.textColor = HexColor(0x2B2C44);
        self.yaoQiuLab.font = [UIFont systemFontOfSize:14];
        self.yaoQiuLab.textAlignment = NSTextAlignmentRight;
        [self.bgView addSubview:self.yaoQiuLab];
        
        self.jiaZhiTitleLab = [UILabel new];
        self.jiaZhiTitleLab.textColor = HexColor(0x9C9DB3);
        self.jiaZhiTitleLab.font = [UIFont systemFontOfSize:14];
        [self.bgView addSubview:self.jiaZhiTitleLab];
        
        self.jiaZhiLab = [UILabel new];
        self.jiaZhiLab.textColor = HexColor(0x2B2C44);
        self.jiaZhiLab.font = [UIFont systemFontOfSize:14];
        self.jiaZhiLab.textAlignment = NSTextAlignmentRight;
        [self.bgView addSubview:self.jiaZhiLab];
    }
    return self;
}

-(void)setModel:(MyTakeOrderDetailMainModel *)model {
    _model = model;
    [self configUI];
}

- (void)configUI {
    self.bgView.nim_left = 15;
    self.bgView.nim_top = 0;
    self.bgView.nim_width = ScreenW - 2 * self.bgView.nim_left;
    
    self.fanWeiTitleLab.text = @"运输范围：";
    self.fanWeiTitleLab.nim_left = 15;
    self.fanWeiTitleLab.nim_top = 20;
    [self.fanWeiTitleLab sizeToFit];
    
    self.fanWeiLab.text = self.model.trans_scope;
    [self.fanWeiLab sizeToFit];
    self.fanWeiLab.nim_left = self.fanWeiTitleLab.nim_right;
    self.fanWeiLab.nim_centerY = self.fanWeiTitleLab.nim_centerY;
    self.fanWeiLab.nim_width = self.bgView.nim_width - 15 - self.fanWeiLab.nim_left;
    
    self.leiXingTitleLab.text = @"运输类型：";
    self.leiXingTitleLab.nim_left = 15;
    self.leiXingTitleLab.nim_top = 10 + self.fanWeiTitleLab.nim_bottom;
    [self.leiXingTitleLab sizeToFit];
    
    self.leiXingLab.text = [NSString stringWithFormat:@"%@,%@",self.model.trans_style,self.model.trans_type];
    [self.leiXingLab sizeToFit];
    self.leiXingLab.nim_left = self.leiXingTitleLab.nim_right;
    self.leiXingLab.nim_centerY = self.leiXingTitleLab.nim_centerY;
    self.leiXingLab.nim_width = self.bgView.nim_width - 15 - self.leiXingLab.nim_left;
    
    self.companyTitleLab.text = @"车主：";
    self.companyTitleLab.nim_left = 15;
    self.companyTitleLab.nim_top = 10 + self.leiXingTitleLab.nim_bottom;
    [self.companyTitleLab sizeToFit];
    
    self.companyLab.text = self.model.tlogistics_name;
    [self.companyLab sizeToFit];
    self.companyLab.nim_left = self.companyTitleLab.nim_right;
    self.companyLab.nim_centerY = self.companyTitleLab.nim_centerY;
    self.companyLab.nim_width = self.bgView.nim_width - 15 - self.companyLab.nim_left;
    
    self.priceTitleLab.text = @"合同报价运输：";
    self.priceTitleLab.nim_left = 15;
    self.priceTitleLab.nim_top = 10 + self.companyTitleLab.nim_bottom;
    [self.priceTitleLab sizeToFit];
    
    self.priceLab.text = self.model.contract;
    [self.priceLab sizeToFit];
    self.priceLab.nim_left = self.bgView.nim_width - 15 - self.priceLab.nim_width;
    self.priceLab.nim_centerY = self.priceTitleLab.nim_centerY;
    
    self.timeTitleLab.text = @"提货时间：";
    self.timeTitleLab.nim_left = 15;
    self.timeTitleLab.nim_top = 10 + self.priceTitleLab.nim_bottom;
    [self.timeTitleLab sizeToFit];
    
    self.beignTimeLab.text = self.model.start_time;
    [self.beignTimeLab sizeToFit];
    self.beignTimeLab.nim_left = self.bgView.nim_width - 15 - self.beignTimeLab.nim_width;
    self.beignTimeLab.nim_centerY = self.timeTitleLab.nim_centerY;
    
    self.endTimeLab.text = self.model.end_time;
    [self.endTimeLab sizeToFit];
    self.endTimeLab.nim_left = self.bgView.nim_width - 15 - self.endTimeLab.nim_width;
    self.endTimeLab.nim_top = self.beignTimeLab.nim_bottom + 10;
    
    self.beginDotView.nim_width = 4;
    self.beginDotView.nim_height = 4;
    self.beginDotView.nim_left = (self.beignTimeLab.nim_width > self.endTimeLab.nim_width ? self.beignTimeLab.nim_left : self.endTimeLab.nim_left) - 10 - self.beginDotView.nim_width;
    self.beginDotView.nim_centerY = self.beignTimeLab.nim_centerY;
    
    self.endDotView.nim_width = 4;
    self.endDotView.nim_height = 4;
    self.endDotView.nim_left = self.beginDotView.nim_left;
    self.endDotView.nim_centerY = self.endTimeLab.nim_centerY;
    
    self.timeLine.nim_width = 2;
    self.timeLine.nim_height = self.endDotView.nim_top - self.beginDotView.nim_bottom - 4;
    self.timeLine.nim_centerX = self.beginDotView.nim_centerX;
    self.timeLine.nim_top = self.beginDotView.nim_bottom + 2;
    
    self.yaoQiuTitleLab.text = @"要求到达时间：";
    self.yaoQiuTitleLab.nim_left = 15;
    self.yaoQiuTitleLab.nim_top = 10 + self.endTimeLab.nim_bottom;
    [self.yaoQiuTitleLab sizeToFit];
    
    self.yaoQiuLab.text = self.model.arrival_time;
    [self.yaoQiuLab sizeToFit];
    self.yaoQiuLab.nim_left = self.bgView.nim_width - 15 - self.yaoQiuLab.nim_width;
    self.yaoQiuLab.nim_centerY = self.yaoQiuTitleLab.nim_centerY;
    
    self.jiaZhiTitleLab.text = @"保险声明价值：";
    self.jiaZhiTitleLab.nim_left = 15;
    self.jiaZhiTitleLab.nim_top = 10 + self.yaoQiuTitleLab.nim_bottom;
    [self.jiaZhiTitleLab sizeToFit];
    
    self.jiaZhiLab.text = self.model.price;
    [self.jiaZhiLab sizeToFit];
    self.jiaZhiLab.nim_left = self.bgView.nim_width - 15 - self.jiaZhiLab.nim_width;
    self.jiaZhiLab.nim_centerY = self.jiaZhiTitleLab.nim_centerY;
    
    self.bgView.nim_height = self.jiaZhiTitleLab.nim_bottom + 15;
    self.height = self.bgView.nim_bottom;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
